Skip to main content

Orders

Order objects are created to handle end customers' purchases of already existing products. You can create, retrieve and update individual orders, as well as list all orders. Orders are identified by a unique autogenerated ID as well as an external ID set by yourself.

Base URL

All following endpoints operates over the URL of your store: https://your-store.com/

example: https://alephdigital.publica.la/

Endpoints

For all type of Order

Headers

{
"Content-Type": "application/json",
"Accept": "application/json",
"X-User-Token": {api_token}
}
info

Make sure you generated the api_token on your store. More info HERE

First of all, there are three types of orders.

  • Permission orders: Used to assign a publication or plan to a user. Although it grants access, it doesn't count as a transaction in the sales report, and therefore, it won't be displayed in the sales report.
  • Report orders: Allows the creation of users and products if they do not exist, assigns a publication or plan to a user, generates a transaction in the sales report without going through a gateway, and automatically marks it as approved by default.
  • Sale orders: Used to generate a checkout session in a gateway. The order will remain in the 'pending' status until the user completes its payment in the gateway. If the payment is successful, the order then transitions to the 'approved' status. Once the order transitions to the 'approved' status, it can be viewed in Dashboard-Sales. This order also grants access to a publication or plan, and it will be reported as a transaction in the sales report.

Create Permission

POST /integration-api/v1/orders

example: https://your-store.com/integration-api/v1/orders

Automatic creation of missing resources:

When creating sale,permission and report orders, if the user doesn't exist, it's created automatically. That's why the user.id is required.

Body Request for permission

FieldDescriptionRequiredTypeFormat
typeOrder typeyesstringpermission
external_referenceOrder unique ID in your systemnostringmax 64
return_urlAn url to return to, after finishing the checkoutnostringurl
unit_priceOrder pricenofloat
currency_idOrder currencynostringISO 4217. All supported for permission. Only ARS supported for sale or report
userUser objectyesobject
user.idUser unique ID in your systemyesstringmax 64
user.emailUser Emailyesstringemail
productsList of productsyesobjects array
products.*.typeProduct typeyesstringcontent or subscription
products.*.idProduct unique ID in your systemyesstringmax 64
products.*.nameProduct namenostringmax 64. (*) It's required only when using the automatic creation of products
products.*.urlProduct urlnostringurl. (*) It's required only when using the automatic creation of products
products.*.unit_priceProduct pricenofloat
products.*.currency_idProduct currencynostringISO 4217. All supported for permission. Only ARS supported for sale or report
products.*.expiration_dateUser will lose access to the content at this datenostringyyyy-mm-dd

JSON example for permission order:

{
"external_reference": "123-abc",
"user":{
"id": "123",
"email": "[email protected]"
},
"products": [{
"id": "123",
"type": "content",
"expiration_date": "2023-12-31"
}]
}

Response

FieldDescriptionTypeFormat
idpublica.la's order unique IDstring
external_referenceOrder unique ID in your systemstring
typeOrder creation typestringpermission
unit_priceOrder pricefloat
currency_idOrder currencystringISO 4217
statusstring
created_atDate when the order was created.stringyyyy-mm-dd
userobject
user.idUser unique ID in your systemstringmax 64
user.emailUser emailstringemail
productsList of productsobjects array
products.*.idProduct unique ID in your systemstring
products.*.typestringcontent or subscription
products.*.namestring
products.*.statusstring
products.*.expiration_dateUser will lose access to the content at this datestringyyyy-mm-dd
products.*.coverstring
products.*.reader_urlstring
products.*.unit_pricefloat

JSON example for permission:

{  
"data":
{
"id" : "03033649-de10-404b-aa8a-8682871001c2",
"external_reference": "123-abc",
"type": "permission",
"unit_price": 12.9,
"currency_id": "USD",
"status": "approved",
"created_at": "2021-08-01",
"user":{
"id": "123",
"email": "[email protected]"
},
"products": [{
"id": "abc-123",
"type": "content",
"name": "abc product",
"status": "approved",
"expiration_date": "2021-12-31",
"cover": "https://cdn.publica.la/item/3213123.jpg",
"reader_url": "https://domain.com/reader/abc-product",
"description": "abc product is...",
"pages_quantity": 12,
"file_type": "pdf",
"is_free": false,
"unit_price": 10
}]
}
}

Create Report

POST /integration-api/v1/orders

example: https://your-store.com/integration-api/v1/orders

Automatic creation of missing resources:

When creating sale,permission and report orders, if the user doesn't exist, it's created automatically. That's why the user.id is required.

Body Request for Report

FieldDescriptionRequiredTypeFormat
typeOrder typeyesstringreport
external_referenceOrder unique ID in your systemnostringmax 64
return_urlAn url to return to, after finishing the checkoutyesstringurl
unit_priceOrder priceyesfloat
currency_idOrder currencyyesstringISO 4217. All supported for permission. Only ARS supported for sale
userUser objectyesobject
user.idUser unique ID in your systemyesstringmax 64
user.emailUser Emailnostringemail
productsList of productsyesobjects array
products.*.typeProduct typeyesstringcontent or subscription
products.*.idProduct unique ID in your systemyesstringmax 64
products.*.nameProduct nameyes*stringmax 64. (*) It's required only when using the automatic creation of products
products.*.urlProduct urlyes*stringurl. (*) It's required only when using the automatic creation of products
products.*.unit_priceProduct priceyesfloat
products.*.currency_idProduct currencyyesstringISO 4217. All supported for permission. Only ARS supported for sale or report
products.*.expiration_dateUser will lose access to the content at this datenostringyyyy-mm-dd

JSON example for sale order:

{
"unit_price": 25,
"type": "report",
"currency_id": "USD",
"return_url": "https://www.google.com",
"user":{
"email": "[email protected]"
},

"products": [{
"id": "product-002",
"type": "content",
"unit_price": 25,
"currency_id": "USD"
}]
}

Response

FieldDescriptionTypeFormat
idpublica.la's order unique IDstring
external_referenceOrder unique ID in your systemstring
typeOrder creation typestringsale
unit_priceOrder pricefloat
currency_idOrder currencystringISO 4217
statusstring
created_atDate when the order was created.stringyyyy-mm-dd
userobject
user.idUser unique ID in your systemstringmax 64
user.emailUser emailstringemail
productsList of productsobjects array
products.*.idProduct unique ID in your systemstring
products.*.typestringcontent or subscription
products.*.namestring
products.*.statusstring
products.*.expiration_dateUser will lose access to the content at this datestringyyyy-mm-dd
products.*.coverstring
products.*.reader_urlstring
products.*.unit_pricefloat

**JSON example for report:

{
"data": {
"id": "d052f749-6bab-40d7-b188-24fbad7bc97a",
"external_reference": null,
"type": "report",
"unit_price": 25,
"currency_id": "USD",
"user": {
"id": null,
"email": "[email protected]"
},
"status": "approved",
"created_at": "2024-05-09",
"products": [
{
"id": "product-002",
"type": "content",
"name": "product-002",
"status": "approved",
"expiration_date": null,
"unit_price": 25,
"currency_id": "USD",
"cover": "https://farfalla.localhost/images/cover-image-02.png",
"reader_url": "http://farfalla.localhost"
}
]
}
}

Create Sale

POST /integration-api/v1/orders

example: https://your-store.com/integration-api/v1/orders

Automatic creation of missing resources:

When creating sale,permission and report orders, if the user doesn't exist, it's created automatically. That's why the user.id is required.

When creating sale orders only, if the product doesn't exist, it's created automatically. For this to happen, we need the product fields name and url, in addition to the fields already "required for sale".
The newly created product will be type "External link" and it will be pointing to that url. It will only be accessible through the API or the store dashboard, it won't be displayed in the storefront.

Completing the checkout for sale orders

When creating a sale order, the response will include a checkout.token property containing an external-auth-token url and checkout.ttl with its ttl in seconds. You should redirect your user to that URL, and we'll automatically authenticate them and redirect them to the corresponding gateway checkout. After they complete the payment, they will be redirected to the return_url you set for your order.
We will add a query string to that return_url containing the following payment data:

  • order-id: The order ID in our system
  • order-external-id: The order ID in your system
  • status: the resulting status after the payment (approved, pending, cancelled)

Keep in mind that a checkout.token expires after checkout.ttl seconds, you can always generate a new one manually or by retrieving the order using the GET endpoint

Body Request for Sale

FieldDescriptionRequiredTypeFormat
typeOrder typeyesstringsale
external_referenceOrder unique ID in your systemnostringmax 64
return_urlAn url to return to, after finishing the checkoutyesstringurl
unit_priceOrder priceyesfloat
currency_idOrder currencyyesstringISO 4217. All supported for permission. Only ARS supported for sale
userUser objectyesobject
user.idUser unique ID in your systemyesstringmax 64
user.emailUser Emailnostringemail
productsList of productsyesobjects array
products.*.typeProduct typeyesstringcontent or subscription
products.*.idProduct unique ID in your systemyesstringmax 64
products.*.nameProduct nameyes*stringmax 64. (*) It's required only when using the automatic creation of products
products.*.urlProduct urlyes*stringurl. (*) It's required only when using the automatic creation of products
products.*.unit_priceProduct priceyesfloat
products.*.currency_idProduct currencyyesstringISO 4217. All supported for permission. Only ARS supported for sale or report
products.*.expiration_dateUser will lose access to the content at this datenostringyyyy-mm-dd

JSON example for sale order:

{
"external_reference": "123-abc",
"type": "sale",
"unit_price": 10,
"currency_id": "ARS",
"user":{
"id": "123",
"email": "[email protected]"
},
"products": [{
"id": "123",
"type": "content",
"unit_price": 10,
"currency_id": "ARS"
}]
}

Response

FieldDescriptionTypeFormat
idpublica.la's order unique IDstring
external_referenceOrder unique ID in your systemstring
typeOrder creation typestringsale
unit_priceOrder pricefloat
currency_idOrder currencystringISO 4217
statusstring
created_atDate when the order was created.stringyyyy-mm-dd
userobject
user.idUser unique ID in your systemstringmax 64
user.emailUser emailstringemail
productsList of productsobjects array
products.*.idProduct unique ID in your systemstring
products.*.typestringcontent or subscription
products.*.namestring
products.*.statusstring
products.*.expiration_dateUser will lose access to the content at this datestringyyyy-mm-dd
products.*.coverstring
products.*.reader_urlstring
products.*.unit_pricefloat

JSON example for sale (when just created and still pending):

{  
"data":
{
"id" : "03033649-de10-404b-aa8a-8682871001c2",
"external_reference": "123-abc",
"checkout": {
"url": "https://your-store.com/auth/token?external-auth-token={AUTH-TOKEN}",
"expires_on" : "2023-01-01 12:00:00"
},
"type": "sale",
"unit_price": 10,
"currency_id": "ARS",
"status": "pending",
"created_at": "2021-08-01",
"user":{
"id": "123",
"email": "[email protected]"
},
"products": [{
"id": "abc-123",
"type": "content",
"name": "abc product",
"status": "pending",
"cover": "https://cdn.publica.la/item/3213123.jpg",
"reader_url": "https://domain.com/reader/abc-product",
"description": "abc product is...",
"pages_quantity": 12,
"file_type": "pdf",
"is_free": false
}]
}
}
CodeDescription
200Ok
201Object Created
422Validation error, the reason of the error will be described in the response body
401Unauthenticated

JSON with errors example:

{
"status": 422,
"errors": [{
"title": "Incorrect User ID",
"details": ["Creation of the order failed due to incorrect user id"]
}]
}

Get

Using this endpoint you can either paginate through all the orders, search for orders by different parameters, or get a specific order by ID

GET /integration-api/v1/orders/{id || external_reference}?id_type= &user_email= &product_id &product_type= &start_at= &end_at=

tip

Using query parameter you can filter by id_type, user_email, product_id, product_type, or by date range using start_at, end_at.

examples:

  • Getting a specific order by the ID in our system:
    https://your-store.com/integration-api/v1/orders/some-id?id_type=internal
  • Getting a specific order by the ID in your system:
    https://your-store.com/integration-api/v1/orders/some-other-id?id_type=external
  • Searching for orders by product_id
    https://your-store.com/integration-api/v1/orders?product_id=some-product-id&product_type=content
  • Searching for orders by date range
    https://your-store.com/integration-api/v1/orders?start_at=2022-01-01&end_at=2022-06-01
  • Searching for orders by user email
    https://your-store.com/integration-api/v1/[email protected]
  • Getting all your orders
    https://your-store.com/integration-api/v1/orders

Parameters

FieldDescriptionTypeRequiredFormat
idMain or internal Order IDstringnomax 64
external_referenceExternal reference or order IDstringonly if id_type=externalmax 64

Query Params

FieldDescriptionTypeRequiredFormat
id_typeID typestringonly when we set an ID or external_reference parameterinternal or external
user_idUser unique ID in your systemstringIt is prioritized over user_emailmax 64
user_emailUser Emailstringemail
product_typestringonly when we set a product_idcontent or subscription
product_idProduct ID in your systemstringmax 64
start_atDate when the order was createdstringyyyy-mm-dd
end_atDate when the order was createdstringyyyy-mm-dd

Response

FieldDescriptionTypeFormat
idpublica.la's order unique IDstring
external_referenceOrder unique ID in your systemstring
checkout.tokenWhen the order is pending, the url to continue the checkoutstring
checkout.ttlWhen the order is pending, the ttl in secondsinteger
typeOrder creation typestringinternal,sale,permission and report
unit_priceOrder pricefloat
currency_idOrder currencystringISO 4217
created_atDate when the order was created.stringyyyy-mm-dd
statusStatus of the orderstringapproved, cancelled, pending, paused
userContains details of the user.object
user.idUser unique ID in your systemstring
user.emailUser Emailstring
productsContains details of the product.array objectContains details of the products.
products.idProduct unique ID in your systemstring
products.typestringcontent or subscription
products.namestring
products.statusstring
products.expiration_dateUser will lose access to the content at this datestringyyyy-mm-dd
products.coverstring
products.reader_urlstring
products.unit_pricefloat

JSON example:

{"data": [{
"id": "c9f2b7b0-dc74-4c58-92a7-9dfcf93aed38",
"external_reference": "123-abc",
"unit_price": 17,
"currency_id": "USD",
"type": "sale",
"user": {
"id": "123",
"email": "[email protected]"
},
"status": "approved",
"created_at": "2022-01-18",
"products": [
{
"id": "978-987-805-082-9",
"type": "content",
"name": "Lorem Ipsum",
"cover": "https://storage/thumbnail.jpg",
"expiration_date": "2023-12-31",
"reader_url": "https://domain.com/reader/lorem-ipsum",
"description": "",
"pages_quantity": 324,
"file_type": "PDF",
"is_free": false,
"unit_price": 17,
"status": "approved"
}
]
}]
}

Update

PUT /integration-api/v1/orders/{id || external_reference}?id_type=

example: https://your-store.com/integration-api/v1/orders/123-abc?id_type=external

This endpoint can update:

  • expiration date
  • status
note

At least one of the two values is required.

status can change as follows:

  • status: paused Only those orders Approved
  • status: cancelled Only those orders Paused o Approved
  • status: approved Only those orders Paused
note
  • If expiration_date is sent as null, it is interpreted that expiration_date should be removed and left null
  • The status cancelled is a final status which cannot be modified. :::

Parameters

FieldDescriptionTypeRequiredFormat
idMain or internal Order IDstringyes, when we don’t have an external_referencemax 64
external_referenceExternal reference or order IDstringyes, when we don't have an idmax 64

Query params

FieldRequiredTypeFormat
id_typeyes, when using external_reference it should be externalstringinternal or external
product_idnostringmax 64
product_typeConditional. Required if product_id is not null.content or subscription

Body request

FieldRequiredTypeFormat
expiration_dateConditional. Required if status is null.stringyyyy-mm-dd
statusConditional. Required if expiration_date is null.stringcancelled, approved or paused
{
"expiration_date": "2023-12-31",
"status" : "paused"
}

Response

FieldDescriptionTypeFormat
idpublica.la's order unique IDstring
external_referenceOrder unique ID in your systemstringstring
typeOrder creation typestringinternal, sale, permission or report
unit_priceOrder pricefloat
currency_idOrder currencystringISO 4217
created_atDate when the order was created.stringyyyy-mm-dd
statusStatus of the orderstringapproved, cancelled, pending, paused
userContains details of the user.object
user.idUser unique ID in your systemstring
user.emailUser Emailstring
productsContains details of the product.array objectContains details of the products.
products.idProduct unique ID in your systemstring
products.typestringcontent or subscription
products.namestring
products.statusstring
products.expiration_dateUser will lose access to the content at this datestringyyyy-mm-dd
products.coverstring
products.reader_urlstring
products.unit_pricefloat

JSON example:

{  
"data": {
"id": "03033649-de10-404b-aa8a-8682871001c2",
"external_reference": "123-abc",
"unit_price": 12.9,
"currency_id": "USD",
"user":{
"id": "123",
"email": "[email protected]"
},
"status": "approved",
"created_at": "2020-04-13",
"products": [
{
"id": "abc-123",
"type": "content",
"name": "abc product",
"expiration_date": "2023-12-13",
"cover": "https://cdn.publica.la/item/3213123.jpg",
"reader_url": "https://domain.com/reader/abc-product",
"description": "abc product is...",
"pages_quantity": 12,
"file_type": "PDF",
"is_free": false,
"unit_price": 10,
"status": "approved"
}
]
}
}

CodeDescription
200Ok
201Object Created
422Validation error, the reason of the error will be described in the response body
401Unauthenticated

JSON with errors example:

{
"status": 422,
"errors": [{
"title": "Incorrect expiration date format",
"details": ["Update failed due to incorrect expiration date format"]
}]
}

Cancel

DELETE /integration-api/v1/orders/{id || external_reference}?id_type=

example: https://your-store.com/integration-api/v1/orders/123-abc?id_type=external

Once deleted, the cancelled status cannot be reversed. :::

Parameters

FieldDescriptionTypeRequiredFormat
idMain or internal Order IDstringyes, when we don’t have an external_referencemax 64
external_referenceExternal reference or order IDstringyes, when we don't have an idmax 64

Query params

FieldRequiredTypeFormat
id_typeyes, when using external_reference it should be externalstringinternal or external

Body request

FieldDescriptionRequiredTypeFormat
reasonSet a reason why you cancel or revoke the access to the user.nostringmax 150
expiration_dateUser will lose access to the content at this date. If it is not specified and it is a subscription, it will be canceled once the current period has ended, otherwise the cancellation will be immediate.nostringyyyy-mm-dd

Response

FieldDescriptionType
idMain or internal order IDstring
external_referenceExternal reference or order IDstring

JSON example:

{  
"data": [
{
"id": "03033649-de10-404b-aa8a-8682871001c2",
"external_reference": "123-abc"
}
]
}
CodeDescription
200Ok
422Validation error, the reason of the error will be described in the response body
401Unauthenticated